/*
 *  Copyright (C) 2010 Glauco
 * 
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.balisunrise.common.defaults;

import java.util.ArrayList;
import java.util.List;
import org.balisunrise.annotation.FilterType;
import org.balisunrise.common.Criterion;
import org.balisunrise.common.abstracts.AbstractBasic;

/**
 *
 * @author Glauco
 */
public class DefaultBaliCriterion extends AbstractBasic implements Criterion{

    private FilterType filterType;
    private boolean emptyForAll;
    private String fieldName;
    private List<String> fieldPreNames;
    private Object value;
    private Object otherValue;

    public DefaultBaliCriterion(String fieldName){
        this.fieldName = fieldName;
        fieldPreNames = new ArrayList<String>();
    }

    @Override
    public String getFieldName() {
        return fieldName;
    }

    @Override
    public String[] getPreNames() {
        return fieldPreNames.toArray(new String[]{});
    }

    @Override
    public void addPreName(String preName) {
        if(preName != null)
            fieldPreNames.add(preName);
    }

    @Override
    public Object getValue() {
        return value;
    }

    @Override
    public void setValue(Object value) {
        this.value = value;
    }

    @Override
    public Object getOtherValue() {
        return otherValue;
    }

    @Override
    public void setOtherValue(Object otherValue) {
        this.otherValue = otherValue;
    }

    @Override
    public FilterType getFilterType() {
        return filterType;
    }

    @Override
    public void setFilterType(FilterType filterType) {
        this.filterType = filterType;
    }

    @Override
    public boolean isEmptyForAll() {
        return emptyForAll;
    }

    @Override
    public void setEmptyForAll(boolean emptyForAll) {
        this.emptyForAll = emptyForAll;
    }

    @Override
    public String toString() {
        return "DefaultBaliCriterion{"
                + "filterType=" + filterType +
                "   fieldName=" + fieldName +
                "   value=" + value +
                "   otherValue=" + otherValue + '}';
    }
}
